home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 June: Reference Library / Dev.CD Jun 95 / Dev.CD Jun 95.toast / What's New? / New System Software Extensions / QuickDraw 3D ß / Programming / Unsupported Libraries / Error_Lib.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-06  |  2.6 KB  |  119 lines  |  [TEXT/MPS ]

  1. /******************************************************************************
  2.  **                                                                             **
  3.  **     Module:        Error_Lib.c                                                  **
  4.  **                                                                          **
  5.  **                                                                          **
  6.  **     Purpose:                                                               **
  7.  **                                                                          **
  8.  **                                                                          **
  9.  **                                                                          **
  10.  **     Copyright (C) 1992-1994 Apple Computer, Inc.  All rights reserved.     **
  11.  **                                                                          **
  12.  **                                                                          **
  13.  **     Change Log:                                                             **
  14.  **                                                                          **
  15.  **                                                                          **
  16.  *****************************************************************************/
  17. #include <stdio.h>
  18.  
  19. #include "QD3D.h"
  20. #include "QD3DErrors.h"
  21.  
  22. #include "Error_Lib.h"
  23. #include "Error_MesgLib.h"
  24.  
  25. FILE *gErrorFile = NULL;
  26.  
  27. static void    ErrorHandler(
  28.     TQ3Error     firstError,
  29.     TQ3Error        lastError,
  30.     long        reference);
  31.     
  32. static void    WarningHandler(
  33.     TQ3Warning     firstWarning,
  34.     TQ3Warning     lastWarning,
  35.     long        reference);
  36.     
  37. static void    NoticeHandler(
  38.     TQ3Notice     firstNotice,
  39.     TQ3Notice     lastNotice,
  40.     long        reference);
  41.  
  42. void InstallDefaultErrorHandler(
  43.     void)
  44. {
  45.     if (gErrorFile == NULL)
  46.         gErrorFile = fopen("error.output","w+");
  47.         
  48.     Q3Error_Register(ErrorHandler, 0);
  49. }
  50.  
  51.  
  52. void InstallDefaultWarningHandler(
  53.     void)
  54. {
  55.     if (gErrorFile == NULL)
  56.         gErrorFile = fopen("error.output","w+");
  57.         
  58.     Q3Warning_Register(WarningHandler, 0);
  59. }
  60.  
  61.  
  62. void InstallDefaultNoticeHandler(
  63.     void)
  64. {
  65.     if (gErrorFile == NULL)
  66.         gErrorFile = fopen("error.output","w+");
  67.         
  68.     Q3Notice_Register(NoticeHandler, 0);
  69. }
  70.  
  71. static void ErrorHandler(
  72.     TQ3Error     firstError,
  73.     TQ3Error     lastError,
  74.     long        reference)
  75. {
  76.     char buf[512];
  77.     
  78.     sprintf(buf, "First ERROR %d:%s\n", firstError, getErrorString(firstError));
  79.     if (lastError != kQ3ErrorNone)
  80.         sprintf(buf, "\tLast ERROR %d:%s\n", lastError, getErrorString(lastError));
  81.  
  82.     fputs(buf,stdout);
  83.     if (gErrorFile != NULL)
  84.         fputs(buf, gErrorFile);
  85. }
  86.  
  87.  
  88. static void WarningHandler(
  89.     TQ3Warning     firstWarning,
  90.     TQ3Warning     lastWarning,
  91.     long        reference)
  92. {
  93.     char buf[512];
  94.     
  95.     sprintf(buf, "First WARNING %d:%s\n", firstWarning, getWarningString(firstWarning));
  96.     if (lastWarning != kQ3WarningNone)
  97.         sprintf(buf, "\tLast WARNING %d:%s\n", lastWarning, getWarningString(lastWarning));
  98.  
  99.     fputs(buf,stdout);
  100.     if (gErrorFile != NULL)
  101.         fputs(buf, gErrorFile);
  102. }
  103.  
  104. static void NoticeHandler(
  105.     TQ3Notice     firstNotice,
  106.     TQ3Notice     lastNotice,
  107.     long        reference)
  108. {
  109.     char buf[512];
  110.     
  111.     sprintf(buf, "First NOTICE %d:%s\n", firstNotice, getNoticeString(firstNotice));
  112.     if (lastNotice != kQ3NoticeNone)
  113.         sprintf(buf, "\tLast NOTICE %d:%s\n", lastNotice, getNoticeString(lastNotice));
  114.  
  115.     fputs(buf,stdout);
  116.     if (gErrorFile != NULL)
  117.         fputs(buf, gErrorFile);
  118. }
  119.